home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-03-29 | 13.5 KB | 169 lines | [TEXT/ALFA] |
- \ Section: 65C02 Instructions
-
- \ ADC - Add to Accumulator with Carry
-
- \ set processor status flags
- : psADC ( v -- )
- >r r FF > if r 100 - rA ! #C set else #C unset then \ carry
- r 0= if #Z set else #Z unset then \ zero
- r 7F > if #N set else #N unset then \ negative
- r> 80 and oldA @ 80 and <> if #V set else #V unset then \ overflow
- ;
-
- : doADC
- inline{ rA @ dup oldA ! + #C @v + dup rA ! psADC }
- ;
-
- \ code
- : $69 imm. doADC ; \ immediate
- : $65 zpg. doADC ; \ zero page
- : $75 zpx. doADC ; \ zero page,rX
- : $72 zpi. doADC ; \ zero page indirect
- : $6D abs. doADC ; \ absolute
- : $7D abx. doADC ; \ absolute,rX
- : $79 aby. doADC ; \ absolute,rY
- : $61 inx. doADC ; \ indirect,rX
- : $71 iny. doADC ; \ indirect,rY
-
- \ AND - and Memory with Accumulator
-
- : psAND
- dup 0= if #Z set else #Z unset then \ zero
- 7F > if #N set else #N unset then ; \ negative
-
- : doAND inline{ rA @ and dup rA ! psAND } ;
-
- : $29 imm. doAND ; \ immediate
- : $25 zpg. doAND ; \ zero page
- : $32 zpi. doAND ; \ zero page indirect
- : $35 zpx. doAND ; \ zero page,rX
- : $2D abs. doAND ; \ absolute
- : $3D abx. doAND ; \ absolute,rX
- : $39 aby. doAND ; \ absolute,rY
- : $21 inx. doAND ; \ indirect,rX
- : $31 iny. doAND ; \ indirect,rY
-
-
- \ ASL - Accumulator Shift Left
-
- : psASL dup FF > if 100 - #C set else #C unset then
- dup 0= if #Z set else #Z unset then
- dup 7F > if #N set else #N unset then
- ;
-
- : $0A rA @ 2* psASL rA ! ; \ accumulator
- : $06 zpg. 2* psASL addr @ $! ; \ zero page
- : $16 zpx. 2* psASL addr @ $! ; \ zero page,rX
- : $0E abs. 2* psASL addr @ $! ; \ absolute
- : $1E abx. 2* psASL addr @ $! ; \ absolute,rX
-
-
- \ BCC - Branch on Carry Clear
-
- : $90 imm. #C @ if drop else branch0 then ;
-
- \ BCS - Branch on Carry Set
-
- : $B0 imm. #C @ if branch0 else drop then ;
-
- \ BEQ - Branch on result Equal to Zero
-
- : $F0 imm. #Z @ if branch0 else drop then ;
-
- \ BIT - Test Bits in Memory with Accumulator
-
- : doBIT ( n -- ) \ perform a BIT operation
- dup dup
- 80 and 0= if #N unset else #N set then
- 40 and 0= if #V unset else #N set then
- rA @ and 0= if #Z set else #Z unset then ;
-
- : $89 imm. rA @ and 0= if #Z set else #Z unset then ;
- : $24 zpg. doBIT ;
- : $34 zpx. doBIT ;
- : $2C abs. doBIT ;
- : $3C abx. doBIT ;
-
- \ BMI - Branch on result minus
-
- : $30 imm. #N @ if branch0 else drop then ;
-
- \ BNE - Branch on result not equal to zero
-
- : $D0 imm. #Z @ if drop else branch0 then ;
-
- \ BPL - Branch on result plus
-
- : $10 imm. #N @ if drop else branch0 then ;
-
- \ BRA - Branch relative always
-
- : $80 imm. branch0 ;
-
- \ BRK - Break - enters the program whose address is $F7FE lo $F7FF hi
-
- : $00 0F7FE $@ 0F7FF $@ >addr rPC ! ;
-
- \ BVC - Branch on overflow clear
-
- : $50 imm. #V @ if drop else branch0 then ;
-
- \ BVS - Branch on overflow set
-
- : $70 imm. #V @ if branch0 else drop then ;
-
- \ CLC - Clear Carry Flag
-
- : $18 #C unset ;
-
- \ CLD - Clear Decimal Flag
-
- : $D8 #D unset ;
-
- \ CLI - Clear Interrupt Disable
-
- : $58 #I unset ;
-
- \ CLV - Clear overflow flag
-
- : $B8 #V unset ;
-
- \ CMP - Compare Memory and Accumulator
-
- : doCMP
- dup rA @ swap < if #N set #Z unset #C unset drop else
- dup rA @ = if #Z set #C set #N unset drop else
- rA @ swap > if #C set #Z unset #N unset then
- then then ;
-
- : $C9 imm. doCMP ;
- : $C5 zpg. doCMP ;
- : $D5 zpx. doCMP ;
- : $D2 zpi. doCMP ;
- : $CD abs. doCMP ;
- : $DD abx. doCMP ;
- : $D9 aby. doCMP ;
- : $C1 inx. doCMP ;
- : $D1 iny. doCMP ;
-
- \ CPX - Compare Memory and rX
-
- : doCPX
- dup rX @ swap < if #N set #Z unset #C unset drop else
- dup rX @ = if #Z set #C set #N unset drop else
- rX @ swap > if #C set #Z unset #N unset then
- then then ;
-
- : $E0 imm. doCPX ;
- : $E4 zpg. doCPX ;
- : $EC abs. doCPX ;
-
- \ CPY - Compare Memory and rY
-
- : doCPY
- dup rY @ swap < if #N set #Z unset #C unset drop else
- dup rY @ = if #Z set #C set #N unset drop else
- rY @ swap > if #C set #Z unset #N unset then
- then then ;
-
- : $C0 im